package com.qianxun.module.application.rest;


import com.qianxun.module.application.entity.Application;
import com.qianxun.module.application.service.ApplicationService;
import com.qianxun.module.base.constant.Result;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 应用信息前端处理器
 *
 * @author Admin
 */
@RequestMapping("/app")
@RestController
public class ApplicationController {

    @Resource
    private ApplicationService baseService;

    @RequestMapping("/queryByAppId/{appId}")
    public Result queryByAppId(@PathVariable("appId") String appId) {
        if (StringUtils.isBlank(appId)) {
            return Result.fail("操作失败");
        }
        Application application = baseService.getByAppId(appId);
        return Result.success(application);
    }


    @RequestMapping("/queryById/{id}")
    public Result queryById(@PathVariable("id") Integer id) {
        Application application = baseService.getById(id);
        return Result.success(application);
    }


    @RequestMapping("/queryByPid/{pid}")
    public Result queryByPid(@PathVariable("pid") Integer pid, List<String> appIds) {
        List<Application> applications = baseService.queryByPid(pid, appIds);
        return Result.successList(applications);
    }

}
